define(function (require, exports) {
	/**
	 * 页面加载完成时触发
	 * @param hashCode 路由ID
	 * @param data 传递数据对象
	 * @param cite 页面站点信息
	 */
	exports.ready = function (hashCode, data, cite) {
		yufp.custom.vue({
			el: cite.el,
			data: function () {
				yufp.lookup.reg('USE_ALARM_TYPE,USE_ALARM_MODE,USE_ALARM_STATE');
				var _this = this;
				return {
					tbHeight:'0',
					dataUrl: 'api/use/monitor/warningMonitor/queryList',
					searchFormdata: {},
					formdata: {},
					refreshInterval: 60000,
					height: yufp.frame.size().height,
					formDisabled: false,
					viewTitleArrry: ['警示信息'],
					viewTitle: '',
					setIntervalId: 0,
					dialogVisible: false,
					queryName: "",
					intervalSelection: {
						key: '60000',
						label: '60秒'
					},
					refreshIntervalOptions: [{ key: '864000000', label: '不自动刷新' }, { key: '10000', label: '10秒' }, { key: '20000', label: '20秒' }, { key: '30000', label: '30秒' }, { key: '60000', label: '60秒' }]
				};
			},
			mounted() {
				var _this = this;
				//测试
				_this.$nextTick(function(){
						var tableBox = _this.$refs.tableBox;
						let a = tableBox.getBoundingClientRect().top + 28;
						var theight = `calc(100vh - ${a}px - 100px)`;
						_this.tbHeight = theight;		
				});
				this.refreshTable(_this.refreshInterval)
			},
			watch: {

				refreshInterval(val) {
					var _this = this;
					clearInterval(_this.setIntervalId);
					_this.setIntervalId = setInterval(fn, _this.refreshInterval);
					function fn() {
						clearInterval(_this.setIntervalId);
						_this.$refs.refTable.remoteData("");
						_this.setIntervalId = setInterval(fn, _this.refreshInterval);
					}
				}
			},
			methods: {
				selectIntervalFn: function (val) {
					var _this = this
					if (val instanceof Object) {
						_this.refreshInterval = val.key
					} else {
						_this.refreshInterval = val
					}
				},
				refreshTable: function () {
					var _this = this;

					_this.setIntervalId = setInterval(fn, _this.refreshInterval);
					function fn() {
						clearInterval(_this.setIntervalId);
						_this.$refs.refTable.remoteData("");
						_this.setIntervalId = setInterval(fn, _this.refreshInterval);
					}
				},
				dealStateFormatter: function (row, column, cellValue) {
					if (cellValue != null && cellValue !== "" && cellValue.length != 0) {
						return "已处理"
					} else {
						return "未处理"
					}
				},
				sendMsg: function (alarmObj) {
					var _this = this;

					yufp.service.request({
						method: 'POST',
						url: "api/use/monitor/warningMonitor/sendMsg",
						data: alarmObj,
						callback: function (code, message, response) {
							if (response.code != 0) {
								_this.$message({ message: response.message, type: "warning" });
							} else {
								var param = { condition: JSON.stringify(_this.searchFormdata) };
								_this.$refs.refTable.remoteData(param);
								_this.$message("操作成功");
							}

						}
					});
				},

/* 				dealStateFormatter: function (row, column, val) {
					if (row.dealTime == null) {
						return "未处理";
					} else {
						return "已处理";
					}
				}, */

				resendMsg: function (alarmObj) {
					this.sendMsg(alarmObj);
				},

				checkDetial: function (alarmObj) {
					var _this = this;
					_this.dialogVisible = true;
					_this.viewTitle = _this.viewTitleArrry[0];
					_this.isReadOnly = false;
					var val = alarmObj;
					// console.log(val);
					_this.$nextTick(function () {
						_this.$refs.refForm.resetFields();
						_this.formdata.warningTitle = val.alarmTitle;
						_this.formdata.warningText = val.alarmText;
						// _this.formdata.dialogText= val;

					});
				},
				cancelFn: function () {
					var _this = this;
					this.dialogVisible = false;
				}
			}

		});
	};
});